package com.study.utils;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class HelloHbase {

    public static void main(String[] args) throws IOException {

        Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum", "192.168.53.134");
        Connection conn = ConnectionFactory.createConnection(config);

        //HBaseAdmin hBaseAdmin = new HBaseAdmin(config);
        Admin hBaseAdmin = conn.getAdmin();
        HTableDescriptor tableDescriptor = new HTableDescriptor("userinfos");
        HColumnDescriptor column1 = new HColumnDescriptor("column1");
        tableDescriptor.addFamily(column1);
        hBaseAdmin.createTable(tableDescriptor);
        hBaseAdmin.close();

        System.out.println("ok");
    }
}

